﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;

public partial class Agency_company_isprint : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
        _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
        if (HZ.MBSM.BLL.Login.CheckAssert(_AccountType))
        {

            GridViewShow();
        }
    }
    private void GridViewShow()
    {
        int i = 0;
        Db db = new Db();
        DbPage dbPage = new DbPage(db);
        dbPage.Table = " SupplyPlan_Goods ";                                               //要查询的表明
        dbPage.Key = "SupplyPlan_Goods.goodsid  ";
        dbPage.SelectFieldGroup = "usercode_tb,companyname_tb,isuse";//表的主键    
        dbPage.Where = fctConditions();                                        //查询条件    
        dbPage.SelectField = @"usercode_tb as 中标企业编号,companyname_tb as 中标企业名称,
sum( case projectid when 8 then 1 else 0 end)  as 原中标,
sum( case projectid when 9 then 1 else 0 end)  as 自行采购,
sum( case projectid when 10 then 1 else 0 end)  as [22种降价品种],
sum( case projectid when 11 then 1 else 0 end)  as 血液制品,
sum( case projectid when 12 then 1 else 0 end)  as 重点监控,
case isuse when 1 then '通过' when 2 then  '撤废' end as 状态";
//要显示的字段
        //要显示第几页   
        //没有显示记录条数   
        dbPage.OrderBy = "中标企业编号";

        dbPage.PageIndex = SysFun.ToInt(Request["CurrentlyPageIndex"]);
        dbPage.PageSize = 20;
        this.GridView1.DataSource = dbPage.ExecuteReaderGroup(30);
        this.GridView1.DataBind();
        this.DbPageFlip1.DbPage = dbPage;
        db.Close();
    }
    public string fctConditions()
    {
        string strmap = "  memo1 is null and";
        if (this.usercode_TB.Text.ToString().Trim() != "") 
        {
            strmap += " UserCode_TB='" + this.usercode_TB.Text + "' and";
        }
        if (this.companyname_TB.Text.ToString().Trim() != "")
        {
            strmap += " CompanyName_TB like '%" + this.companyname_TB.Text.ToString() + "%' and";
        }
        strmap = strmap.Substring(0, strmap.Length - 3);

        return strmap;
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        string usercode_TBmany = Request.Form["chk"].ToString();
        string updatesql = "update SupplyPlan_Goods set isuse=2,NopassExplain='" + this.NopassExplain.Text.ToString() + "' where UserCode_TB in ('" + usercode_TBmany + "')";
        Db db = new Db();
        db.Command(updatesql);
        db.Close();
        Response.Redirect("company_isprint.aspx");

    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        string usercode_TBmany = Request.Form["chk"].ToString();
        string updatesql = "update SupplyPlan_Goods set isuse=1 where UserCode_TB in ('" + usercode_TBmany + "')";
        Db db = new Db();
        db.Command(updatesql);
        db.Close();
        Response.Redirect("company_isprint.aspx");
    }
}
